package com.chezhujie.www.service;

import java.util.List;
import java.util.Map;

import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.chezhujie.www.core.page.Pagination;
import com.chezhujie.www.domain.Czjadvertcount;
import com.chezhujie.www.persistence.CzjadvertcountMapper;
import com.chezhujie.www.utils.UUIDUtils;


@Service
public class CzjadvertcountService {


    @Autowired
    private CzjadvertcountMapper czjadvertcountMapper;

	public Pagination getCzjadvertcount(Map<String, Object> map,
			Integer pageSize, Integer pageNo) {
		
		Pagination p = new Pagination();
		p.setPageNo(pageNo);
		p.setPageSize(pageSize);
		map.putAll(p.toMap());
		int count=czjadvertcountMapper.getTotalRows1(map);
		List<Czjadvertcount> list=	czjadvertcountMapper.getAdvertcount(map);
	
		p.setList(list);
		p.setTotalCount(count);
		return p;
	}

	public Pagination getCzjadvertcountByurl(Map<String, Object> map,
			Integer pageSize, Integer pageNo) {
		Pagination p = new Pagination();
		p.setPageNo(pageNo);
		p.setPageSize(pageSize);
		map.putAll(p.toMap());
		int count=czjadvertcountMapper.getTotalRows1Byurl(map);
		List<Czjadvertcount> list=	czjadvertcountMapper.getAdvertcountByurl(map);
	
		p.setList(list);
		p.setTotalCount(count);
		return p;
	}

	public void insertAdvertcount(Czjadvertcount czjadvertcount) {
		if(StringUtils.isBlank(czjadvertcount.getAdvertcountId())){
				czjadvertcount.setAdvertcountId(UUIDUtils.getDateUUID());
		}
			czjadvertcountMapper.insertCzjadvertcount(czjadvertcount);
	}
   


}
